import { BasicColumn, FormSchema } from '@/components/Table';
import { h, ref } from 'vue';
import { Tag } from 'ant-design-vue';
import {VxeFormItemProps, VxeGridPropTypes} from "@/components/VxeTable";
import util from "@/utils/util";
import { kqDeptSelect } from '@/api/heng/production';



/**
 */
export const vxeTableColumns: VxeGridPropTypes.Columns = [
  {
    title: '序号',
    type: 'seq',
    width: '30',
    align: 'center',
  },

  {
    title: '姓名',
    field: 'userName',
    align: 'center',
    width: 80,
  },
  {
    title: '是否连班',
    field: 'izLianBan',
    align: 'center',
    formatter: ({ cellValue, row, column }) => {
      let val = "";
      if(cellValue==null){
        return val;
      }
      if(cellValue==1){
        val="是";
      }
      if(cellValue==0){
        val="否";
      }
      return val;
    },
    width: 80,
  },
  {
    title: '小组',
    field: 'groupName',
    showOverflow: 'title',
    width: 150,
    align: 'center',
  },
  {
    title: '组长',
    field: 'groupUserName',
    align: 'center',
    width: 80,
  },
  {
    title: '创建时间',
    field: 'createTime',
    width: 70,
    formatter: ({ cellValue, row, column }) => {
      let val = util.formatDate(new Date(cellValue));
      return val;
    },
    align: 'center',
  },
  {
    width: 100,
    title: '操作',
    align: 'center',
    field: '',
    slots: { default: 'action' },
    fixed: 'right',
  },
];




export const vxeTableFormSchema: VxeFormItemProps[] = [
  {
    span: 12,
    field: 'keyword',
    title: '搜索',
    itemRender: {
      props: {
        placeholder: '姓名',
      },
      name: 'AInput',
    },
  },
  {
    span: 12,
    field: 'groupName',
    title: '小组',
    itemRender: {
      props: {
        placeholder: '小组',
      },
      name: 'AInput',
    },
  },

  {
    span: 24,
    itemRender: {
      name: 'VxeButtonGroup',
      options: [
        { type: 'reset', content: '重置' },
        { type: 'submit', content: '查询', status: 'primary' },
      ],
    },
  },
];


export const formSchema: FormSchema[] = [
  {
    field: 'userId',
    label: 'userId',
  },
  {
    field: 'userName',
    label: '姓名',
    component:"Input",
   // dynamicDisabled:
    dynamicDisabled: ({ values }) => values.userId,
    required: true,
  },
  {
    field: 'kqGroupId',
    label: '小组',
    component:"ApiSelect",
    componentProps: {
      style:{width:'100%'},
      api: kqDeptSelect,
      resultField:"data.list",
      labelField: 'groupName',
      valueField: 'id',
    },
    required: true,
  },
  {
    field: 'izLianBan',
    label: '是否连班',
    component:"Select",
    componentProps: {
      style:{width:'100%'},
      options: [
        { label: '否', value: 0 },
        { label: '是', value: 1 },
      ],
    },
    required: false,
  },

];
